-
-
Notifications
You must be signed in to change notification settings - Fork 99
Fix unhelpful error message for missing constraint bounds #960
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When a constrained optimization problem is defined with `cons` but without `lcons` and `ucons`, the error message was "no method matching keys(::Nothing)" which was confusing. Now it provides a clear error message that explains the missing parameters and includes an example. Fixes #959 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Implementation DetailsProblem AnalysisThe issue occurred when users provided a constrained optimization problem (with SolutionAdded validation checks in both
Files Changed
Test ResultsThe new tests verify that:
The fix has been tested locally and all tests pass. Process Notes
|
Following user feedback, the constraint validation is now done uniformly across all solvers through a common utility function `_check_constrained_problem` in utils.jl. This ensures consistent error messages and behavior across all constraint-supporting solvers. Changes: - Added _check_constrained_problem utility function in utils.jl - Updated LBFGS and AugLag to use the utility function - Added validation to all other constraint-supporting solvers: - OptimizationNLopt - OptimizationOptimJL (IPNewton) - OptimizationPRIMA (COBYLA, LINCOA) - OptimizationEvolutionary - OptimizationSciPy (ScipyMinimize, ScipyShgo) - OptimizationMOI (NLP) - OptimizationNOMAD This provides a more maintainable solution that ensures all solvers give the same helpful error message when constraint bounds are missing. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
@ChrisRackauckas I've updated the PR based on your feedback. The constraint validation is now done uniformly across all solvers using a common utility function. Changes made:
This ensures that all constraint-supporting solvers will give the same helpful error message when users forget to provide The tests still pass and the error message remains the same helpful one: |
|
no this should be on the higher level solve dispatch |
|
@ChrisRackauckas You're absolutely right - this should be in SciMLBase.jl for a truly uniform solution. I've created a PR in SciMLBase.jl that adds the validation there: SciML/SciMLBase.jl#1080 The validation is now added to the
Once the SciMLBase PR is merged, we can close this PR in Optimization.jl since the fix will be at the appropriate level in the stack. |
Summary
lconsanduconswhen a constrained optimization problem is definedTest plan
lconsanduconsare properly providedFixes #959
🤖 Generated with Claude Code